from DebugTrace import DebugTrace

class ThermistorStub(object):
    def __init__(self, MinTemp, MaxTemp, HoldingTemp, HeaterStub, CurrentTemp,traceLevel=1):
        self.MinTemp = MinTemp;
        self.MaxTemp = MaxTemp;
        self.HoldingTemp = HoldingTemp;
        self.HeaterStub = HeaterStub;
        if CurrentTemp==None:
            self.CurrentTemp = MinTemp;
        else:
            self.CurrentTemp = CurrentTemp;

        self.trace = DebugTrace("Thermistor",traceLevel)
        
    def getCurrentTemp(self):
        if self.HeaterStub.getHeaterState()==0:
            if self.CurrentTemp>self.MinTemp:
                self.CurrentTemp-=1;
                self.trace.trace(3,"Fake temperature decreased to "+str(self.CurrentTemp))
        else:
            if self.CurrentTemp<self.MaxTemp:
                self.CurrentTemp+=1;
                self.trace.trace(3,"Fake temperature increased to "+str(self.CurrentTemp))
        return self.CurrentTemp;
    
    def getHoldingTemp(self):
        return self.HoldingTemp;
    
    def setHoldingTemp(self, temp):
        self.HoldingTemp = temp;
